<template>
	<view class="content1">
		<navbar @goBack="goBack" title="消费记录"></navbar>
		<view class="package-box" style="padding-bottom: 90rpx">
			<view v-for="(item, index) in List" :key="index" class="gift-box">
				<view class="white-content" style="font-size: 28rpx"> {{ item.type }} </view>
				<view class="image-box" @click="selectitem(item, index)">
					<view class="lflex">
						<text class="price">订单编号:</text>
						<text class="price"
							style="text-align:right">{{ item.trade_num }}</text>
					</view>
					<view class="lflex">
						<text class="price">产品描述</text>
						<text class="price">{{ item.game_type }} </text>
					</view>
					<view class="lflex">
						<text class="price">官方零售价:</text>
						<text class="price">￥{{ (item.price / 100).toFixed(2) }}
						</text>
					</view>
					<!-- <view class="lflex">
						<text class="price">数量:</text>
						<text class="price">x {{ item.count }}
						</text>
					</view>
					<view class="lflex">
						<text class="price">优惠金额:</text>
						<text class="price">￥{{ (item.discount / 100).toFixed(2) }}
						</text>
					</view>
					<view class="lflex">
						<text class="price">消费总金额:</text>
						<text class="price">￥{{ ((item.price*item.count-item.discount) / 100).toFixed(2) }}
						</text>
					</view> -->

				</view>
			</view>
		</view>

		<view class="empty-page" v-if="List.length==0">
			<view class="nofull">
				<image src="../../static/icons/package/nofull.png" class="nofullimg"></image>
				<text class="notitle">暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import moment from "moment";
	import {
		billslist
	} from "@/api/user";
	import navbar from '@/wxcomponents/navbar'
	export default {
		components:{
			navbar
		},
		data() {
			return {
				List: [],
				total: 0,
				page: 1
			};
		},
		onLoad: function(options) {
			this.billslist();
		},
		onReachBottom() {
			if (this.List.length < this.total) {
				++this.page
				this.billslist();
			}
		},
		async onPullDownRefresh() {
			this.page = 1
			await this.billslist();
			uni.stopPullDownRefresh()
		},
		methods: {
			convertDateTime(iosDate) {
				if (!iosDate) {
					return "-";
				}
				const date = new Date(iosDate);
				const year = date.getFullYear();
				const month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的
				const day = ("0" + date.getDate()).slice(-2);
				const hours = ("0" + date.getHours()).slice(-2);
				const minutes = ("0" + date.getMinutes()).slice(-2);
				const seconds = ("0" + date.getSeconds()).slice(-2);

				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
			goBack() {
				uni.navigateBack({
					delta: 1,
				});
			},
			// 未申请
			async billslist() {
				if (this.loading) {
					return
				}
				this.loading = true
				var obj = {
					page: this.page,
					size: 10,
				}
				const res = await billslist(obj);
				const data = res.data || {};
				const items = data.items || [];
				if (this.page == 1) {
					this.List = items;
				} else {
					this.List = this.List.concat(items);
				}
				this.total = data.total
				this.loading = false
			},
		},
	};
</script>

<style lang="scss">
	@import "src/static/scss/common";
	.package-box {
		// background-color: #0a050b;
	}

	.gift-box {
		display: flex;
		flex-direction: column;
		padding: 24rpx;
		background-color: #42424E;
		margin: 24rpx;
		border: solid 1rpx rgba(255, 255, 253, 0.31);

		.image-box {
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			position: relative;

			.price {
				font-size: 23rpx;
				color: #a1a1a1;
			}
		}

		.lflex {
			width: 100%;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			margin-top: 16rpx;
		}
	}

	.app-container {
		flex-direction: column;
	}

	/* 标签栏样式 */
	.menu-tabs .van-tab--active {
		color: #ffffff;
		/* 字体颜色 */
		background-color: #ff8917;
		/* 标签背景颜色 */
		border-radius: 40px;
		/* 圆角标签背景 */
	}

	.menu-tabs {
		.van-tabs__line {
			background-color: #ff55ff;
			/* 线条颜色 */
			width: 40px;
			/*宽度 */
			height: 10px;
			/* 高度 */
			border-radius: 40px;
			/* 圆角 */
		}

		--tabs-nav-background-color: rgba(10, 5, 11, 1);
	}
</style>